# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
# Note: This package contains only header files.
pkgname=rapidjson
pkgver=1.1.0
pkgrel=6
pkgdesc="Fast JSON parser/generator for C++ with both SAX/DOM style API"
url="http://rapidjson.org/"
arch="noarch"
license="MIT"
makedepends="cmake samurai"
checkdepends="gtest gtest-dev"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/miloyip/rapidjson/archive/v$pkgver.tar.gz
	do-not-include-gtest-src-dir.patch
	disable-march-cxx-flag.patch
	disable-Werror.patch
	gcc14.patch
	"

build() {
	CXXFLAGS="$CXXFLAGS -std=c++14" \
	cmake -B build -G Ninja . \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_VERBOSE_MAKEFILE=ON \
		-DRAPIDJSON_BUILD_DOC=OFF \
		-DRAPIDJSON_BUILD_EXAMPLES=OFF \
		-DRAPIDJSON_BUILD_CXX11=OFF \
		-DGTESTSRC_FOUND=ON \
		-DGTEST_SOURCE_DIR=.
	cmake --build build
}

check() {
	cd build
	ctest -E '.*valgrind.*' -V .
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	# Remove examples and readme.
	rm -r "$pkgdir"/usr/share
}

sha512sums="
2e82a4bddcd6c4669541f5945c2d240fb1b4fdd6e239200246d3dd50ce98733f0a4f6d3daa56f865d8c88779c036099c52a9ae85d47ad263686b68a88d832dff  rapidjson-1.1.0.tar.gz
b6027268c3a10c602ab3df783790d3af537a9f23e74651bdd0a0dc6810144eeba37f15e12576f4b357e538c634e979b7c128e95294e60788f59d69ccb8367f6f  do-not-include-gtest-src-dir.patch
7b5b0a33cec087358841a6c8ec38c68f510ccb0eef33894e8b6c5fa8d41c6bcdd46015f71a0888156f87bd809b52318aae17703faff63579248994d98f8a540f  disable-march-cxx-flag.patch
8f62dd40a51f9502e6b358c6752a7ab82f1ab4b557bfb946798fda912c61ac5dd6163311842ac3ab9b17866168c0d07f69b75e5e8daf8a55a7b76ec965b6fc08  disable-Werror.patch
5002ff20a65b7d057411e39adf7f5a29eddff818d20579900b655df4d838b984a1b68f488232e1990b592943a70943619d924da1c4e1d2ce0d3ef65bc40f75d6  gcc14.patch
"
